{{extend 'layout.html'}}
{{block sectionclass}}ticket{{end}}
<!-- begin "ticket" block -->
<h2>{{=T('Error ticket')}} for "{{=app}}"</h2>
<h3>{{=T('Ticket ID')}}</h3>
<p>{{=ticket}}</p>
{{if output:}}<h4>{{=output}}</h4>{{pass}}
<h3>{{=T('Version')}}</h3>
<table class="versions">
<tbody>
	<tr>
	<th>web2py&trade;</th>
	<td>{{=myversion}}</td>
	</tr>
	{{if snapshot:}}
	<tr>
	<th>Python</th>
	<td>{{=snapshot.get('pyver','')}}</td>
	</tr>
	{{pass}}
</tbody>
</table>
{{if traceback or code or layer:}}
	<h3>{{=T('Traceback')}}</h3>
	<div class="inspect resp1">{{=traceback}}</div>
	{{if snapshot:}}
		{{try:}}
			<!-- ERROR SNAPSHOT -->
			<h3>{{=T('Error snapshot')}}
				<a href="#" rel="tooltip" data-placement="right" data-original-title="{{=T('Detailed traceback description')}}">
				{{=helpicon()}}
				<span>{{=T("Detailed traceback description")}}</span>
				</a>
			</h3>
			<!-- SNAPSHOT LIST -->
			<div id="snapshot">
				<!-- Exception details -->
				<p class="exception_object inspect">
					<code>{{=snapshot['etype']}}({{=snapshot['evalue']}})</code>
				</p>
				<p class="controls">
					<a class="button btn" onclick="collapse('exception_inner');"><span>{{=T('inspect attributes')}}</span></a>
				</p>
				<div id="exception_inner" class="hide">
					<div class="inspect">
						<h5>{{=T("Exception instance attributes")}}</h5>
						<table>
							<tbody>
								{{for k,v in snapshot['exception'].items():}}
								<tr>
									<th>{{=k}}</th>
									<td>{{=v}}</td>
								</tr>
								{{pass}}
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<!-- FRAMES -->
			<div id="frames">
				<h4>{{=T('Frames')}}</h4>
				<ul class="unstyled">
					{{for i, frame in enumerate(snapshot['frames']):}}
					<li>
						{{is_hidden = (i != len(snapshot['frames'])-1 and 'hide' or 'inspect')}}
						<div class="framefile inspect controls">
							<p>
								<strong>File {{="%s in %s at line %s" % (frame['file'], frame['func'], frame['lnum'])}}</strong>
								<a class="button tbbutton btn" onclick="collapse('{{='%s_code_inner' % i}}');"><span>{{=T("code")}}</span></a>
								<a class="button tbbutton btn" onclick="collapse('{{='%s_args_inner' % i}}');"><span>{{=T("arguments")}}</span></a>
								<a class="button tbbutton btn" onclick="collapse('{{='%s_vars_inner' % i}}');"><span>{{=T("variables")}}</span></a>
							</p>
							<div id="{{='%s_args_inner' % i}}" class="{{=is_hidden}}" style="width:100%;overflow:auto">
								<h5>Function argument list</h5>
								<p>{{=frame['call']}}</p>
							</div>
							<div id="{{='%s_code_inner' % i}}" class="{{=is_hidden}}" style="width:100%;overflow:auto">
								<h5>Code listing</h5>
								{{if frame['lines']:}}
									<pre>{{=CODE('\n'.join([x[1] for x in sorted(frame['lines'].items(),key=lambda x: x[0])]),
										language='python', link=None, counter=min(frame['lines'].keys()), highlight_line=frame['lnum'])}}</pre>
								{{pass}}
							</div>
							<div id="{{='%s_vars_inner' % i}}" class="{{=is_hidden}}" style="width:100%;overflow:auto">
								<h5>Variables</h5>
								<table>
									<tbody>
										{{for k,v in frame['dump'].items():}}
										<tr>
											<th>{{=k}}</th>
											<td>{{=v}}</td>
										</tr>
										{{pass}}
									</tbody>
								</table>
							</div>
						</div>
					</li>
					{{pass}}
				</ul>
			</div>
			<!-- VIEW ENVIRONMENT -->
			<div class="viewenv">
				<h4><span>Context</span></h4>
				<p class="controls">
					<a class="button btn" onclick="jQuery('#locals').slideToggle()"><span>{{=T('locals')}}</span></a>
					<a class="button btn" onclick="jQuery('#request').slideToggle()"><span>{{=T('request')}}</span></a>
					<a class="button btn" onclick="jQuery('#session').slideToggle()"><span>{{=T('session')}}</span></a>
					<a class="button btn" onclick="jQuery('#response').slideToggle()"><span>{{=T('response')}}</span></a>
				</p>
				<div class="hide inspect resp1" id="locals"><h6>locals</h6>
				{{try:}}
				{{=BEAUTIFY(snapshot['locals'])}}
				{{except:}}
				{{=BEAUTIFY('no locals available in snapshot')}}
				{{pass}}
				</div>
				<div class="hide inspect" id="request"><h6>request</h6>
				{{try:}}
				{{=BEAUTIFY(snapshot['request'])}}
				{{except:}}
				{{=BEAUTIFY('no request available in snapshot')}}
				{{pass}}
				</div>
				<div class="hide inspect" id="session"><h6>session</h6>
				{{try:}}
				{{=BEAUTIFY(snapshot['session'])}}
				{{except:}}
				{{=BEAUTIFY('no session available in snapshot')}}
				{{pass}}
				</div>
				<div class="hide inspect" id="response"><h6>response</h6>
				{{try:}}
				{{=BEAUTIFY(snapshot['response'])}}
				{{except:}}
				{{=BEAUTIFY('no response available in snapshot')}}
				{{pass}}
				</div>
			</div>
		{{except Exception, e:}}
			<!-- this should not happen, just in case... (cannot output normal hmtl as we don't know current open tags) -->
			{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }}
			<script language='javascript'>alert("Exception during snapshot rendering: {{=tb}} ");</script>
		{{pass}}
	{{pass}}
	<div class="errorsource">
		<h3>In file: {{=layer}}</h3>
		{{=CODE(code.replace('\r',''),language='python',link='/examples/global/vars/')}}
	</div>
{{else:}}
	<h3>{{=T('Ticket Missing')}}</h3>
{{pass}}
<!-- end "ticket" block -->